#pragma once

#include <functional>
#include <string>
#include <chrono>

// 任务优先级
enum class TaskPriority
{
    LOW,
    MEDIUM,
    HIGH,
    CRITICAL
};

// 获取任务结果枚举
enum class TaskFetchResult
{
    SHOULD_EXIT,
    NO_TASK,
    HAS_TASK
};

// 任务的状态
enum class TaskStatus
{
    WAITING,
    RUNNING,
    COMPLETED,
    FAILED,
    CANCELED,
    NOT_FOUND
};


// 任务的信息结构

struct TaskInfo
{
    std::function<void()> task;                           // 任务
    TaskPriority priority;                                // 任务的优先级
    std::chrono::steady_clock::time_point submitTime;     // 任务的提交时间
    std::string taskId;                                   // 任务的id
    std::string description;                              // 任务的描述
    TaskStatus status = TaskStatus::WAITING;              // 任务的状态
    std::string errorMessage;                             // 任务的错误信息
    std::chrono::milliseconds timeout{0};                 // 任务超时时间(毫秒)，0表示无超时限制

    TaskInfo(std::function<void()> task = nullptr, 
             TaskPriority p = TaskPriority::MEDIUM, 
             std::string id = "", 
             std::string desc = "",
             std::chrono::milliseconds timeout = std::chrono::milliseconds(0));
    
    bool operator<(const TaskInfo& othor) const;
};


/******辅助函数******/

// 任务的状态转字符串
std::string taskStatusToString(TaskStatus status);

std::string priorityToString(TaskPriority priority);